import 'package:sainbainu/common/apis/account_api.dart';
import 'package:sainbainu/common/apis/user_api.dart';
import 'package:sainbainu/common/models/request/apple_auth_request.dart';
import 'package:sainbainu/common/models/request/bind_mobile_request.dart';
import 'package:sainbainu/common/models/request/official_auth_request.dart';

import 'package:sainbainu/common/models/request/pager_request.dart';
import 'package:sainbainu/common/models/request/password_request.dart';
import 'package:sainbainu/common/models/request/real_auth_request.dart';
import 'package:sainbainu/common/models/response/my_account.dart';

class AccountRepository {
  final AccountApi _accountApi;

  AccountRepository(this._accountApi);

  /// 修改密码
  Future<Map<String, dynamic>> setPasswd(
    PasswordRequest passwordRequest,
  ) async {
    var res = await _accountApi.setPasswd(passwordRequest.toJson());
    return res;
  }

  /// 绑定手机号
  Future<Map<String, dynamic>> bindMobile(
    BindMobileRequest bindMobileRequest,
  ) async {
    var res = await _accountApi.bindMobile(bindMobileRequest.toJson());
    return res;
  }

  /// 实名认证
  Future<Map<String, dynamic>> realAuth(
    RealAuthRequest realAuthRequest,
  ) async {
    var res = await _accountApi.realAuth(realAuthRequest.toJson());
    return res;
  }

  /// 官方认证
  Future<Map<String, dynamic>> officialAuth(
    OfficialAuthRequest officialAuthRequest,
  ) async {
    var res = await _accountApi.officialAuth(officialAuthRequest.toJson());
    return res;
  }

  /// 我的账号信息
  Future<MyAccountResponse> myAccountInfo() async {
    var res = await _accountApi.myAccountInfo();
    return MyAccountResponse.fromJson(res['data']);
  }

  /// 绑定微信
  Future<Map<String, dynamic>> bindWechat(String code) async {
    var res = await _accountApi.bindWechat({'code': code});
    return res;
  }

  /// 解绑微信
  Future<Map<String, dynamic>> unBindWechat() async {
    var res = await _accountApi.unBindWechat();
    return res;
  }

  /// 绑定apple
  Future<Map<String, dynamic>> bindApple(
    AppleAuthRequest appleAuthRequest,
  ) async {
    var res = await _accountApi.bindApple(appleAuthRequest.toJson());
    return res;
  }

  /// 解绑apple
  Future<Map<String, dynamic>> unBindApple() async {
    var res = await _accountApi.unBindApple();
    return res;
  }
}
